package com.jch.Dao;

import com.entity.Cinema;
import com.entity.Comment;
import com.entity.Movie;
import com.entity.User;

import java.util.List;

public class CinemaDao extends BaseDao {
    public Cinema queryCinema(Object...params){
        String sql="select * from cinema where cName=?";
        return findBean(Cinema.class,sql,params);

    }
    public List<Cinema> queryCinema(){
        String sql="select * from cinema";
        return findList(Cinema.class,sql);
    }
    /**
     * 根据编号查询单条数据
     *
     * @param id
     * @return
     */
    public Cinema queryCinema(int id) {
        String sql = "select * from cinema where cId=?";
        Object[] params = {id};
        return findBean(Cinema.class, sql, params);
    }

    /**
     * 根据实体类数据更新用户
     *
     * @param cinema
     * @return
     */
    public int updateCinema(Cinema cinema) {
        String sql = "update cinema set cName =?,cAddress=?  where cId=?";
        Object[] params = {cinema.getcName(),cinema.getcAddress(),cinema.getCid()};
        return update(sql, params);
    }

    /**
     * 根据id删除一条数据
     *
     * @param id
     * @return
     */
    public int deleteCinema(int id) {
        String sql = "delete from cinema where cId=?";
        Object[] params = {id};
        return update(sql, params);
    }

    /**
     * 根据用户对象增加一条数据
     *
     //     * @param cinema
     * @return
     */
    public int insertCinema(Cinema cinema) {
        String sql = "insert into cinema values(null,?,?)";
        Object[] params = {cinema.getcName(),cinema.getcAddress()};
        return update(sql, params);
    }
}
